
package com.joysuch.wwyt.bp.enums;

public enum WorkLevels {

    LEVEL0(0, "特级"), LEVEL1(1, "一级"), LEVEL2(2, "二级"), LEVEL3(3, "三级");

    private int id;
    private String name;

    private WorkLevels(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static WorkLevels findByName(String name) {
        WorkLevels[] values = WorkLevels.values();
        for (WorkLevels v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static WorkLevels findById(Integer level) {
        WorkLevels[] values = WorkLevels.values();
        for (WorkLevels v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer level) {
        if (level == null) {
            return null;
        }
        WorkLevels[] values = WorkLevels.values();
        for (WorkLevels v : values) {
            if (v.getId() == level) {
                return v.getName();
            }
        }
        return null;
    }
}
